@import url("./theme.less");
@import url("./common.less");
@import url("./animation.less");
@import url("../Assets/Latex/mathlive-static.css");
@import url("../Assets/Iconfont/iconfont.css");

@import url("./konva-root-footer.less");
@import url("./konva-root-topmenu.less");
@import url("./konva-root-container.less");
@import url("./konva-root-shape-settings.less");
@import url("./konva-root-contextmenu.less");

/** 定义变量尺寸 */
@TopHeight: 50px;
@FooterHeight: 30px;
@PreviewWidth: 140px;
@BorderRadius: 4px;

// 根节点
.konva-root {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    // 主背景颜色
    background-color: var(--konva-background-color, @konva-background-color);
    font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Hiragino Sans GB,
        Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif,
        "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol;

    // 左圆角
    .left-border {
        border-bottom-left-radius: @BorderRadius;
        border-top-left-radius: @BorderRadius;
    }

    // 右圆角
    .right-border {
        border-bottom-right-radius: @BorderRadius;
        border-top-right-radius: @BorderRadius;
    }

    // 菜单蒙层 用于点击关闭关闭菜单用（其实就是个层级关系）
    &-menu-mask {
        // background-color: rgba(65, 70, 75, .3);
        z-index: 9;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
    }

    // loading
    &-loading {
        transition: all 0.3s;
        animation: dialog-enter-animation 0.3s ease-in-out;
        position: absolute;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(5px);
        /* 背景模糊 */
        -webkit-backdrop-filter: blur(5px);
        /* 兼容老版本 Safari */
        z-index: 9999;
        display: flex;
        align-content: center;
        justify-content: center;
        color: var(--konva-main-color, @konva-main-color);
        font-size: 22px;

        &>div {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;

            /* HTML: <div class="loader"></div> */
            .loader {
                margin-right: 10px;
                width: 36px;
                padding: 4px;
                aspect-ratio: 1;
                border-radius: 50%;
                background: var(--konva-main-color, @konva-main-color);
                --_m: conic-gradient(#0000 10%, #000),
                    linear-gradient(#000 0 0) content-box;
                -webkit-mask: var(--_m);
                mask: var(--_m);
                -webkit-mask-composite: source-out;
                mask-composite: subtract;
                animation: l3 1s infinite linear;
            }

            @keyframes l3 {
                to {
                    transform: rotate(1turn);
                }
            }
        }
    }

    // 消息提示
    &-message-box {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: absolute;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 999;

        div {
            margin: 10px 0;
            display: flex;
            align-items: center;
            transition: all 0.2s;
            padding: 10px 20px;

            background-color: #fff;
            border: solid 1px var(--konva-border-color, @konva-border-color);
            border-radius: @BorderRadius;
            box-shadow: 0 0 10px var(--konva-box-shadow-color, @konva-box-shadow-color);
            animation: message-box-animation 0.2s ease-in-out;

            svg {
                width: 20px;
                height: 20px;
                margin-right: 4px;
            }
        }
    }

    // 全局弹窗
    &-dialog {
        animation: dialog-enter-animation 0.2s ease-in-out;
        transition: all 0.2s;
        position: absolute;
        left: 0;
        top: 0;
        height: 100vh;
        width: 100vw;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 11;
        overflow: hidden;
        min-width: 420px;

        &-content {
            animation: dialog-content-enter-animation 0.25s ease-in-out;
            padding: 16px;
            border-radius: @BorderRadius;
            background-color: #fff;
            display: flex;
            flex-direction: column;
        }

        &-header {
            height: 32px;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .title {
                font-size: 18px;
                font-weight: 800;
            }
        }

        &-body {
            flex: auto;
            position: relative;
            height: calc(100% - 64px);
            overflow: hidden;
            overflow-y: auto;
            margin: 10px 0;
        }

        &-footer {
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: flex-end;

            span {
                border-radius: @BorderRadius;
                cursor: pointer;
                margin-left: 10px;
                border: solid var(--konva-border-color, @konva-border-color) 1px;
                padding: 4px 12px;
            }

            .confirm {
                background-color: var(--konva-main-color, @konva-main-color);
                color: #fff;
            }
        }

        // 表格样式
        &-table,
        &-echart {
            height: 100%;
            width: 100%;

            input {
                padding: 0 4px;
                border: none;
                height: 24px;
                line-height: 24px;

                &:focus-visible {
                    outline: none;
                }
            }

            .header {
                margin-bottom: 10px;

                input {
                    border: solid #ccc 1px;
                }
            }

            table {
                width: 100%;
                border-collapse: collapse;

                input {
                    width: 100%;
                    background-color: transparent;
                }

                td,
                th {
                    border: solid #ccc 1px;
                }
            }
        }

        // 表格
        &-table {
            thead tr {
                background-color: #ffe0c0;
            }

            td {
                border: solid rgba(0, 0, 0, 0.3) 1px;
            }

            tbody tr:nth-child(n) {
                background-color: #fafafa;
            }

            tbody tr:nth-child(2n) {
                background-color: #fff6ed;
            }
        }

        // 统计图
        &-echart {
            height: 100%;
            width: 100%;

            select {
                padding: 0 4px;
                border: solid #ccc 1px;
                height: 24px;
                line-height: 24px;

                &:focus-visible {
                    outline: none;
                }
            }

            thead tr th,
            tbody tr td:first-child {
                background-color: #f9e8e5;
            }
        }

        // 公式
        &-latex {
            .mathlive {
                &>* {
                    width: 100%;
                    padding: 4px;

                    &:focus-within {
                        outline: none;
                    }
                }
            }

            &-menu {
                padding: 10px 0;
                border-bottom: solid var(--konva-border-color, @konva-border-color) 1px;

                .active {
                    border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                }

                span {
                    transition: all 0.3s;
                    color: #41464b;
                    padding: 10px 16px;
                    cursor: pointer;

                    &:hover {
                        border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                    }
                }
            }

            &-items {
                padding-top: 10px;
                display: flex;
                flex-wrap: wrap;

                svg {
                    transition: all 0.3s;
                    cursor: pointer;
                    border: solid transparent 1px;
                    border-radius: @BorderRadius;

                    &:hover {
                        background-color: var(--konva-background-color,
                                @konva-background-color );
                        border: solid var(--konva-main-color-2, @konva-main-color-2) 1px;
                    }
                }
            }
        }

        // 富文本
        .richtext-editor {
            &>div {
                height: 100%;
            }

            #editor {
                height: calc(100% - 50px);
            }
        }

        // 自定义配色
        .color-match-container {
            width: 100%;
            height: 96%;

            .menu {
                background-color: #fff;
                margin: 10px 0;
                border-bottom: solid 1px var(--konva-border-color, @konva-border-color);

                span {
                    i {
                        color: var(--konva-main-color, @konva-main-color);
                    }

                    color: #41464b;
                    font-size: 14px;
                    display: inline-block;
                    height: 100%;
                    padding: 10px 4px;
                    margin-right: 10px;
                    transition: all 0.3s;
                    cursor: pointer;
                    border-bottom: solid transparent 2px;

                    &:hover {
                        border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                    }
                }

                .active {
                    border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                }
            }

            .content {
                width: 100%;
                height: calc(100% - 50px);
                display: flex;

                &-box {
                    flex: 1;
                    overflow-y: auto;

                    .line {
                        margin: 4px 0;
                        width: 100%;
                        height: 1px;
                        border-top: solid var(--konva-border-color, @konva-border-color) 1px;
                    }

                    // 自定义
                    .zdy {
                        div {
                            padding: 0 10px;
                            margin: 10px 0;
                            font-size: 14px;
                            height: 28px;
                            align-items: center;
                            justify-content: space-between;
                            display: flex;

                            span {
                                color: #41464b;
                            }

                            input {
                                margin-left: 10px;
                                width: 64px;
                            }
                        }

                        .line {
                            margin: 4px 0;
                            width: 100%;
                            height: 1px;
                            border-top: solid var(--konva-border-color, @konva-border-color) 1px;
                        }
                    }

                    // 图片
                    .image {
                        height: 100%;
                        display: flex;
                        align-items: center;
                        justify-content: center;

                        &-picker {
                            display: flex;
                            align-items: center;
                            justify-content: center;

                            &-box {
                                width: 260px;
                                height: 140px;
                                overflow: hidden;
                                user-select: none;
                                cursor: pointer;
                                transition: all 0.3s;
                                border-radius: @BorderRadius;
                                border: solid var(--konva-border-color, @konva-border-color) 1px;
                                display: flex;
                                align-items: center;
                                justify-content: center;
                                flex-direction: column;

                                img {
                                    width: 100%;
                                    height: 100%;
                                }

                                &:hover {
                                    border: solid var(--konva-main-color, @konva-main-color) 1px;
                                }

                                .title {
                                    display: flex;
                                    justify-content: center;
                                }

                                .tips {
                                    margin-top: 10px;
                                    font-size: 12px;
                                    color: #8b8b8b;
                                    display: flex;
                                    justify-content: center;
                                }
                            }
                        }
                    }

                    // 选择颜色
                    .select {
                        .color-tips {
                            user-select: none;
                            height: 100px;
                            display: flex;
                            flex-direction: column;
                            align-items: center;
                            justify-content: center;

                            &-title {}

                            &-info {
                                margin-top: 10px;
                                font-size: 12px;
                                color: #8b8b8b;
                                display: flex;
                                justify-content: center;
                            }
                        }

                        .color-block {
                            display: flex;
                            align-items: center;
                            justify-content: space-around;
                            flex-wrap: wrap;
                            margin-top: 10px;

                            div {
                                cursor: pointer;
                                width: 40px;
                                height: 40px;
                                margin: 10px;

                                input {
                                    cursor: pointer;
                                    width: 100%;
                                    height: 100%;
                                }
                            }
                        }
                    }
                }

                &-preview {
                    border-left: solid var(--konva-border-color, @konva-border-color) 1px;
                    overflow: hidden;
                    flex: 1;
                    display: flex;
                    flex-direction: column;

                    span {
                        transform: translateX(10px);
                        font-size: 14px;
                        color: #41464b;
                    }

                    canvas {
                        margin: 10px;
                        width: calc(100% - 20px);
                        height: calc(100% - 20px);
                    }
                }
            }
        }

        // 幻灯片模板
        .slide-template {
            height: 100%;
            overflow: hidden;

            .menu {
                background-color: #fff;
                margin: 10px 0;
                border-bottom: solid 1px var(--konva-border-color, @konva-border-color);

                span {
                    color: #41464b;
                    font-size: 14px;
                    display: inline-block;
                    height: 100%;
                    padding: 10px;
                    margin-right: 10px;
                    transition: all 0.3s;
                    cursor: pointer;
                    border-bottom: solid transparent 2px;

                    &:hover {
                        border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                    }
                }

                .active {
                    border-bottom: solid var(--konva-main-color, @konva-main-color) 2px;
                }
            }

            .content {
                display: flex;
                flex-wrap: wrap;
                height: calc(100% - 50px);
                overflow: hidden;
                overflow-y: auto;

                img {
                    margin: 10px;
                    cursor: pointer;
                    width: 220px;
                    height: 120px;
                    transition: all 0.3s;
                    border-radius: @BorderRadius;
                    border: solid var(--konva-border-color, @konva-border-color) 1px;

                    &:hover {
                        border: solid var(--konva-main-color, @konva-main-color) 1px;
                    }
                }
            }
        }
    }
}

/** 全屏预览样式 */
.konva-root-preview {
    display: flex;
    align-items: center;
    justify-content: center;
}